package com.anytrek.demomqtt.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@Validated
@Component
@ConfigurationProperties(prefix = "mqtt")
public class MqttProperties {
    
    @NotBlank(message = "MQTT URL 不能为空")
    private String url;
    
    private String username;
    
    private String password;
    
    @NotBlank(message = "MQTT ClientId 不能为空")
    private String clientId;
    
    @NotBlank(message = "MQTT 订阅主题不能为空")
    private String subTopic;
    
    @NotNull(message = "MQTT QoS 不能为空")
    @Min(value = 0, message = "QoS 值必须在 0-2 之间")
    private Integer qos = 0;
    
    private Integer keepAliveInterval = 60;
    
    private Integer connectionTimeout = 30;
    
    private Integer maxInflight = 100;
    
    private Integer recoveryInterval = 10000;
    
    private Integer completionTimeout = 5000;
    
    private Boolean cleanSession = false;
    
    private Boolean automaticReconnect = true;
}